#include "redpointlabel.h"
#include <QPaintEvent>
#include <QPainter>
#include <QRect>
RedPointLabel::RedPointLabel(QWidget *parent)
    : QLabel(parent)
    , _redPointVisible(false)
{}

void RedPointLabel::slot_RedPointVisible(bool visible)
{
    _redPointVisible = visible;
    update();
}

void RedPointLabel::paintEvent(QPaintEvent *event)
{
    QLabel::paintEvent(event);
    // 绘制小红点
    if (_redPointVisible) {
        // 绘制小红点
        QPainter p(this);
        p.setBrush(Qt::red);
        p.setPen(Qt::NoPen);
        // 圆点矩形
        QRect rect(20, 2, 10, 10);
        p.drawRoundedRect(rect, 5, 5);
    }
}
